home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / CMPLTPAS / SCREEN.PAS < prev    next >
Pascal/Delphi Source File  |  1988-07-15  |  4KB  |  129 lines

  1. {--------------------------------------------------------------}
  2. {                          Screen                              }
  3. {                                                              }
  4. {               Full-screen input demo program                 }
  5. {                                                              }
  6. {                             by Jeff Duntemann                }
  7. {                             Turbo Pascal V5.0                }
  8. {                             Last update 7/14/88              }
  9. {                                                              }
  10. {     From: COMPLETE TURBO PASCAL 5.0  by Jeff Duntemann       }
  11. {    Scott, Foresman & Co., Inc. 1988   ISBN 0-673-38355-5     }
  12. {--------------------------------------------------------------}
  13.  
  14.  
  15. PROGRAM Screen;
  16.  
  17. USES DOS,Crt,BoxStuff;
  18.  
  19. {$V-}  { Allow length mismatch for string VAR parameters.  See 23.4 }
  20.  
  21. CONST
  22.   Capslock      = True;
  23.   NoCapslock   = False;
  24.   Numeric       = True;
  25.   NonNumeric   = False;
  26.  
  27. TYPE
  28.   String80 = String[80];
  29.   String30 = String[30];
  30.   String6  = String[6];
  31.   String4  = String[4];
  32.   String3  = String[3];
  33.  
  34.   NAPRec   = RECORD
  35.                Name    : String30;
  36.                Address : String30;
  37.                City    : String30;
  38.                State   : String3;
  39.                Zip     : String6
  40.              END;
  41.  
  42.  
  43. VAR
  44.   CH            : Char;
  45.   CurrentRecord : NAPRec;
  46.   Edit          : Boolean;
  47.   Quit          : Boolean;
  48.   Escape        : Boolean;
  49.   WIDTH,HEIGHT  : Integer;
  50.   I,J           : Integer;
  51.   R             : Real;
  52.  
  53.  
  54. {$I UHUH.SRC }       { Described in Section 16.11 }
  55. {$I CURSOFF.SRC }    { Described in Section 17.2 }
  56. {$I CURSON.SRC }     { Described in Section 17.2 }
  57. {$I YES.SRC }        { Described in Section 17.2 }
  58. {$I GETSTRIN.SRC }   { Described in Section 15.2 }
  59.  
  60.  
  61. PROCEDURE GetScreen(VAR ScreenData : NAPRec;
  62.                         Edit       : Boolean;
  63.                     VAR Escape     : Boolean);
  64.  
  65. BEGIN
  66.   MakeBox(1,1,79,20,GrafChars);        { Draw the screen box }
  67.   IF NOT Edit THEN WITH ScreenData DO  { If not editing, clear record }
  68.     BEGIN
  69.       Name := ''; Address := ''; City := ''; State := ''; Zip := ''
  70.     END;
  71.   GotoXY(23,2);
  72.   Writeln('<< Name / Address Entry Screen >>');
  73.   WITH ScreenData DO
  74.     BEGIN                        { First draw field frames: }
  75.       GotoXY(5,7);
  76.       Write('>>Customer Name:    |..............................|');
  77.       GotoXY(5,9);
  78.       Write('>>Customer Address: |..............................|');
  79.       GotoXY(5,11);
  80.       Write('>>Customer City:    |..............................|');
  81.       GotoXY(5,13);
  82.       Write('>>Customer State:   |...|');
  83.       GotoXY(5,15);
  84.       Write('>>Customer Zip:     |......| ');
  85.       IF Edit THEN WITH ScreenData DO  { If editing, show current values }
  86.         BEGIN
  87.           GotoXY(26,7);  Write(Name);
  88.           GotoXY(26,9);  Write(Address);
  89.           GotoXY(26,11); Write(City);
  90.           GotoXY(26,13); Write(State);
  91.           GotoXY(26,15); Write(Zip)
  92.         END;                            { Now input/Edit field data: }
  93.       GetString(25,7,Name,30,NoCapslock,NonNumeric,False,R,I,J,Escape);
  94.       IF NOT Escape THEN
  95.         GetString(25,9,Address,30,NoCapslock,NonNumeric,False,R,I,J,Escape);
  96.       IF NOT Escape THEN
  97.         GetString(25,11,City,30,NoCapslock,NonNumeric,False,R,I,J,Escape);
  98.       IF NOT Escape THEN
  99.         GetString(25,13,State,3,Capslock,NonNumeric,False,R,I,J,Escape);
  100.       IF NOT Escape THEN
  101.         GetString(25,15,Zip,6,Capslock,NonNumeric,False,R,I,J,Escape);
  102.     END
  103. END;
  104.  
  105.  
  106. BEGIN        { SCREEN MAIN }
  107.   Edit := False;
  108.   CursorOff;
  109.   REPEAT
  110.     ClrScr;
  111.     GetScreen(CurrentRecord,Edit,Escape);  { Input/Edit a data screen }
  112.     IF Escape THEN Quit := True ELSE       { Quit if ESC pressed }
  113.       BEGIN                                { Otherwise summarize data }
  114.         Quit := False;                     { and ask for approval }
  115.         GotoXY(1,22);
  116.         Write('>>Summary: ');
  117.         WITH CurrentRecord DO
  118.           BEGIN
  119.             Write(Name,'/',Address,'/',Zip);
  120.             GotoXY(1,23); Write('>>OK? (Y/N): ');
  121.             IF YES THEN Edit := False ELSE Edit := True
  122.           END
  123.       END
  124.   UNTIL Quit;
  125.   ClrScr;
  126.   CursorOn
  127. END.
  128.  
  129.